clear all
set more off
cd "[working directory]\Replication_files"
global outreg2_options "lab keep(eligible treated) sortvar(eligible treated) nocons bd(3) sd(3) rd(3) ad(3) adds(Dependent variable mean, r(mean), Percentage difference, percent)"
global control "age hhmale high_edu minor  c4 c5 famsize   poorrg"
global FE "i.countyid"

********************************************************************************
	*** First stage
********************************************************************************
use Household_data_anonymized.dta, clear

	g bd1 = 1
	forvalues bd = 2(-.2)1 {
		
		replace bd1 = (runningrl<`bd' & runningrl>-`bd')
		xi:qui: reg treated  eligible runningrl runningrl_inter $control $FE	if bd1, robust
		
		sum treated if e(sample), mean
		scalar percent=_b[eligible]/r(mean)
		if `bd'==2	outreg2 using ".\Output\Table1.xls", replace  $outreg2_options cttop(`bd')
		if `bd'!=2	outreg2 using ".\Output\Table1.xls", append  $outreg2_options cttop(`bd')
		
	}
	
